<?php
/*
Module Group: wish
Module Group Name: 心愿单
Description: 驾校报名
Version: 1.0
Iconurl: http://www.happyidea.com.cn/resource/wx_icon/default.png
Author: gaoyudong
Display: 1
*/
class wishModule extends Module {
	
	/*
	 * 在构造函数中装载所依赖的类或其他文件
	 */
	function __construct() {
		$this->includePhp('wish', 'wish');
	}
		/*
	 * 激活创建数据库
	*/
	public function activate() {
		Module::importSQL (module_sql_path('wish'));
	}
 
	/*
	 * 调用插件资源
	*/
	public function call($user, $method,$param ) {
		$userName = $user['userName'];
		$actId = $param->actId; 
		switch ($method) {
			case 'index':
				if ($actId == '' || $userName=='') {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				wish::index($actId,$userName,$param->shareId);
				break;
			case 'createWish':
				if ($actId == '' || $userName=='') {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				wish::createWish($actId,$userName);
				break;
			case 'saveWish':
				$pids = $param->pids; 
				$wishText = $param->wishText;
				$fullName = $param->fullName; 
				$mobile = $param->mobile; 
				$address = $param->address;  
				if ($actId == '') {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				if ($pids == '') {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				wish::saveWish($actId,$pids,$userName,$wishText,$fullName,$mobile,$address);
				break;
			case updateOrderInfo:
				wish::updateOrderInfo($param);
				break;
			case 'getOrderDetail':
				if(!isset($param->id)){
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				$wishId=$param->wishId;
				wish::getOrderDetail($param->id,$userName,$wishId);
				break;
			case 'successOrder':
				$wishId=$param->wishId;
				$id=$param->id;
				if($wishId == '' || $id==""){
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				wish::successOrder($id,$userName);
				break;
			case 'saveBuyWish':
				$id=$param->id;
				$oid=$param->oid;
				$wishText=$param->wishText;
				if($id == '' || $oid==""){
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				wish::saveBuyWish($param);
				break;
			case 'getAddrEdit':
				$actId=$param->actId;
				if($actId==""){
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				wish::getAddrEdit($userName,$actId);
				break;
			case 'saveAddress':
				$fullName=$param->fullName;
				$phone=$param->phone;
				$address=$param->address;
				if($fullName=="" || $phone=="" || $address==""){
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				wish::saveAddress($userName,$fullName,$phone,$address);
				break;
		}
	}
}

$module = new wishModule();
Module::addModule($module);
?>